<div id="content" class="postie">
    <h1><?=$data->TITLE?></h1>
    <div id="conversation">
    <?
    $j = 0;
    if($data->postie->conversation) foreach ($data->postie->conversation as $i)
        if($i->earlier):
        ?>
        <div id="earlier"><a href="javascript:getEarlier()">Earlier Messages</a></div>
        <?
        else: include 'apps/postie/template/_item.html'; endif;
    ?>
    </div>
    <form id="form" method="POST" action="/json<?=PREFIX.'/'.APP.'/'.CMD?>">
        <div class="formLineLight">
            <label class="formLabel"><?=_('Your message')?>: </label>
            <span class="textarea"><textarea id="message" class="formLineWide" name="message" tabindex="1"></textarea></span>
            <span class="clear"></span>
        </div>
        <div class="formLineDark">
            <span class="submit">
                <span id="loader" class="loader"><img src="/themes/<?=THEME?>/images/loader.gif" alt="loader" /></span>
                <input name="CID" type="hidden" value="<?=PARAMS?>" />
                <input id="submit" class="submit" type="submit" value="<?=_('Send')?>" tabindex="2" />
                <span class="clear"></span>
            </span>
        <span class="clear"></span>
        </div>
    </form>
</div>
<div id="aside"></div>
<script type="text/javascript">
    $('#message').focus();
    function _complete(r){
        $('<div>').html(eval('(' + r + ')')).appendTo('#conversation');
        $('#message').val('').empty().focus();
        $('#submit').removeAttr('disabled');
        $('#loader').hide();
    }
    function  getEarlier(r){
        tool.post({
            'url':'/json<?=PREFIX.'/'.APP.'/'.CMD?>',
            'data':'CID=<?=PARAMS?>&earlier=1',
            onComplete:function(r){
                $('#earlier').html(eval('(' + r.message + ')'));
            }
        });

        //new Element('div',{'html':JSON.decode(r)}).inject('conversation','bottom');
        //$('message').set('value','').empty().focus();
    }
    tool.form(false,false,true);
</script>
